<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('延期申请情况(电话工单)')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>
                        <li>
                            延期理由：<input type="text" name="delayRN"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addTab('','新增延期申请')">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="editDefer()">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/common/js/common.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "system/mInterior";
    $(function () {
        var options = {
            url: prefix + "/cmnFile/tDeferListJson?sendId="+[[${param.sendId}]],
            uniqueId: "myPkVal",
            createUrl: prefix + "/cmnFile/twfDeferAdd?wfId="+[[${param.wfId}]]+"&sendId="+[[${param.sendId}]],
            removeUrl: prefix + "/cmnFile/removetwfDeferJson",
            detailUrl: prefix + "/cmnFile/tDeferChkNView/{id}",
            modalName: "延期申请",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            columns: [{
                checkbox: true
            },
                {field:'myPkVal',title:'PkId',hidden:true,visible:false},
                {field:'WorkFormNO',title:'工单编号',align:'center'},
                {field:'SDeptName',title:'来自',align:'center',halign:'center'},
                {field:'tmLimit',title:'完成期限',align:'center',sortable:true},
                {field:'tmDelay',title:'延期至',align:'center',sortable:true},
                {field:'DelayRN',title:'延期理由',align:'center',halign:'center',sortable:true},
                {field:'chgState',title:'状态',align:'center',sortable:true,formatter:function(value,row,index){return fmtDeferState(value,row,index);}},
                {field:'ChkDesc',title:'审核备注',align:'center',halign:'center'},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.detailTab('+row.myPkVal+')"><i class="fa"></i>详情</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function editDefer(){
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        var pkId = row[0].myPkVal;
        if (pkId) {
            var url = prefix + "/cmnFile/twfDeferEdit/"+pkId;
            $.modal.openTab('修改延期申请',url);
        }
    }
</script>
</body>
</html>